-
Notifications
You must be signed in to change notification settings - Fork 166
Add DOMException #1040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add DOMException #1040
Conversation
Implemented separately from the other errors because it is defined in terms of WebIDL, where members of an interface are getters on their prototype. See the difference between `JSON.stringify(Object.getOwnPropertyDescriptors(new TypeError()))` vs `JSON.stringify(Object.getOwnPropertyDescriptors(new DOMException()))`.
@@ -285,10 +285,10 @@ function bjson_test_bytecode() | |||
function bjson_test_fuzz() | |||
{ | |||
var corpus = [ | |||
"FBAAAAAABGA=", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this was complaining because of the bytecode version, but I don't know how the corpus was generated so I just incremented it manually...
It's still missing a stack trace when created with the constructor... |
The standard doesn't specify where to put "stack". This follows node instead of browsers because it's more straightforward to implement it this way.
I was confused for a minute because browsers set |
Perhaps you could use Js_NewError and extract it? |
I think that should be fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a small comment, good work!
name = JS_ToCString(ctx, s->name); | ||
for (i = 0; i < countof(js_dom_exception_names_table); i++) { | ||
if (js_dom_exception_names_table[i].name && | ||
!strcmp(js_dom_exception_names_table[i].name, name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use strncmp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thank you. But I don't think strncmp helps here, that would do a prefix check but to catch NUL we need a length check.
Thanks to saghul for noticing.
Implemented separately from the other errors because it is defined in terms of WebIDL, where members of an interface are getters on their prototype.
See the difference between
JSON.stringify(Object.getOwnPropertyDescriptors(new TypeError()))
vsJSON.stringify(Object.getOwnPropertyDescriptors(new DOMException()))
.(Required for btoa/atob and structuredClone; ref. #16, #1032)